package com.yimi.yinhepda.views.kua_yue_spotGoods

import android.content.Intent
import android.os.Bundle
import android.view.KeyEvent
import android.view.MotionEvent
import android.view.View
import android.view.View.OnTouchListener
import android.widget.CompoundButton
import android.widget.HorizontalScrollView
import android.widget.LinearLayout
import com.pda.uce.commom.util.LogUtil
import com.pda.uce.commom.util.MyDialog
import com.pda.ym.db.table.UnloadScanTable
import com.yimi.yinhepda.R
import com.yimi.yinhepda.adapter.KuaYueSpotGoodsAdapter
import com.pda.ym.base.BaseTitleActivity
import com.pda.ym.callbacks.UICallBack
import com.yimi.yinhepda.db.dao.LoadUnloadGroupTableDao
import com.yimi.yinhepda.db.dao.UnloadScanTableDao
import com.yimi.yinhepda.entity.bean.KuaYueChildWaybillEntitiy
import com.yimi.yinhepda.entity.bean.KuaYueTaskDetailEntity
import com.yimi.yinhepda.entity.bean.KuaYueTaskEntity
import com.yimi.yinhepda.entity.response.KuaYueTaskDetailResponse
import com.yimi.yinhepda.event.ScanResult
import com.pda.ym.net.NetRequest
import com.pda.ym.utils.*
import com.yimi.yinhepda.utils.*
import com.yimi.yinhepda.views.load_module.BackoutActivity
import com.yimi.yinhepda.views.load_module.LoadUnloadGroupActivity
import com.yimi.yinhepda.views.unload_module.AddBillcodeActivity
import kotlinx.android.synthetic.main.activity_kuayue_spotgoods.*
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import java.math.BigDecimal
import java.sql.SQLException

/**
 * @author: lj
 * Date: 2020/4/18 14:54
 * Description:跨越到达点货界面
 */
class KuaYueSpotGoodsActivity : BaseTitleActivity(true), CompoundButton.OnCheckedChangeListener {

    companion object {
        //跨越任务集合
        var mDataList = mutableListOf<KuaYueTaskDetailEntity>()
        lateinit var mDetailEntity: KuaYueTaskDetailEntity
    }

    //跨越任务实体
    private var mTaskEntity: KuaYueTaskEntity? = null
    //列表适配器
    private var mAdapter: KuaYueSpotGoodsAdapter? = null
    //配载单是否是第一次扫描标志
    private var isFirstScan = true
    //装卸组参与的装卸人
    private var joinWrokNum: String? = null
    private var joinUserName: String? = null
    //月台号
    private var platformNo: String? = null
    //操作类型，操作码:1 -装车，2- 卸车
    private val operTypeCode = 2
    //输入方式 1-PDA扫描输入,2-手动输入
    private val inputType = 1
    //部门类型
    private var deptType = 0
    //扫描表操作类
    private var mScanTableDao: UnloadScanTableDao? = null

    override fun getPageName(): String {
        return "跨越到达卸车"
    }

    override fun setContentViewId(): Int {
        return R.layout.activity_kuayue_spotgoods
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        btn_modifyGroup.setOnClickListener(this)
        iv_back.setOnClickListener(this)
        btn_add.setOnClickListener(this)
        btn_del.setOnClickListener(this)
        iv_refresh.setOnClickListener(this)
        iv_palletBind.setOnClickListener(this)
        iv_submit.setOnClickListener(this)
        cb_palletBind.setOnCheckedChangeListener(this)
        lv_list.setOnTouchListener(ListViewAndHeadViewTouchLinstener())
        listHead.isFocusable = true
        listHead.isClickable = true
        listHead.setOnTouchListener(ListViewAndHeadViewTouchLinstener())
        lv_list.setOnTouchListener(ListViewAndHeadViewTouchLinstener())

        if (!EventBus.getDefault().isRegistered(this)) {
            //注册事件
            EventBus.getDefault().register(this)
        }

        mScanTableDao = UnloadScanTableDao()

        //任务实体
        mTaskEntity = intent.getSerializableExtra(Common.KUAYUE_TASK_KEY) as KuaYueTaskEntity

        //查询装卸组信息，设置托盘绑定状态
        val loadUnloadGroupTableDao = LoadUnloadGroupTableDao()
        val loadUnLoadGroupTable = loadUnloadGroupTableDao.data
        if (loadUnLoadGroupTable != null) {
            cb_palletBind.isChecked = loadUnLoadGroupTable.isPalletBindCheck
        }
        iv_palletBind.isEnabled = cb_palletBind.isChecked

        //根据任务号查询跨越点货明细
        queryTaskDetail()

        lv_list.setOnItemClickListener { parent, view, position, id ->
            mDetailEntity = mDataList[position]
            val intent = Intent(this@KuaYueSpotGoodsActivity, KuaYueScanDetailActivity::class.java)
            startActivity(intent)
        }
    }

    override fun onResume() {
        super.onResume()
        loadUIAdapter()
    }

    override fun onDestroy() {
        super.onDestroy()

        EventBus.getDefault().unregister(this)
    }

    override fun onClick(v: View?) {
        super.onClick(v)
        when (v?.id) {
            R.id.btn_modifyGroup -> {
                //修改装卸人
                if (exitPalletBindData()) {
                    //有托盘数据不可继续操作
                    return
                }
                val intent = Intent(this, LoadUnloadGroupActivity::class.java)
                intent.putExtra("scanType", Common.SCAN_TYPE_KUAYUE_SPOTGOODS)
                intent.putExtra("loadType", Common.SCAN_TYPE_KUAYUE_SPOTGOODS)
                intent.putExtra("palletBindCheck", cb_palletBind.isChecked)
                intent.putExtra(Common.KUAYUE_TASK_KEY, mTaskEntity)
                startActivity(intent)
            }
            R.id.btn_add -> {
                val intent = Intent(this, AddBillcodeActivity::class.java)
                intent.putExtra("operTypeCode", 3)
                startActivity(intent)
            }
            R.id.btn_del -> {
                val intent = Intent(this, BackoutActivity::class.java)
                //撤销类型：1-分拨自提扫描撤销,2-同行卸车撤销
                intent.putExtra("delType", 2)
                startActivity(intent)
            }
            R.id.iv_back -> {
                if (!exitPalletBindData()) {
                    //无托盘数据可退出
                    finish()
                }
            }
            R.id.iv_refresh -> {
                //根据任务号查询跨越点货明细
                queryTaskDetail()
            }
            R.id.iv_palletBind -> {
                //托盘绑定
                intent = Intent(this, KuaYuePalletBindActivity::class.java)
                startActivity(intent)
            }
            R.id.iv_submit -> {
                //提交
                if (exitPalletBindData()) {
                    //有托盘数据不可继续操作
                    return
                }

                if (mDataList.isNullOrEmpty()) {
                    showToast("无运单可提交！")
                    SoundVibratorManager.playSound(2)
                    return
                }
                //跳转至差异报告界面
                val intent = Intent(this@KuaYueSpotGoodsActivity, KuaYueDifferReportActivity::class.java)
                intent.putExtra(Common.KUAYUE_TASK_KEY, mTaskEntity)
                intent.putExtra("piaoNum", tv_piaoNum.text.toString())
                intent.putExtra("jianNum", tv_jianNum.text.toString())
                intent.putExtra("sPiaoNum", tv_sPiaoNum.text.toString())
                intent.putExtra("sJianNum", tv_sJianNum.text.toString())
                startActivity(intent)
            }
        }
    }

    override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
        if (event.keyCode == KeyEvent.KEYCODE_BACK) {
            if (!exitPalletBindData()) {
                finish()
            }
        }
        return super.onKeyDown(keyCode, event)
    }

    override fun onCheckedChanged(buttonView: CompoundButton?, isChecked: Boolean) {
        when (buttonView?.id) {
            R.id.cb_palletBind -> {
                //托盘绑定
                if (!isChecked) {
                    if (exitPalletBindData()) {
                        //有托盘数据不可继续操作
                        cb_palletBind.isChecked = true
                        return
                    }
                }
                iv_palletBind.isEnabled = isChecked
                //保存勾选状态
                val groupTableDao = LoadUnloadGroupTableDao()
                val loadUnLoadGroupTable = groupTableDao.data
                if (loadUnLoadGroupTable != null) {
                    loadUnLoadGroupTable.isPalletBindCheck = isChecked
                    try {
                        groupTableDao.update(loadUnLoadGroupTable)
                    } catch (e: SQLException) {
                        LogUtil.e(e.toString())
                    }
                }
            }
        }
    }

    override fun handleBarCode(result: String?) {
        if (result == null) {
            SoundVibratorManager.playSound(2)
            showToast("运单号扫描失败")
        } else {
            handleScanResult(result, ScanResult(result, 1, 1))
        }
    }

    /**
     * 处理扫描结果
     * @param operType 1-跨越卸车扫描，2-跨越托盘绑定扫描,3-跨越手动添加卸车扫描
     */
    private fun handleScanResult(result: String, event: ScanResult) {
        val scanLastTime = sharedPreferUtil.getLongValue(Common.SCAN_LAST_TIME)
        val currentTime = System.currentTimeMillis()
        if (isFirstScan || currentTime - scanLastTime > 1000 * 300) {
            isFirstScan = false
            //每次进入界面校验网络时间,或者扫描时间超过五分钟
            val compCode = SharedPreferUtil.getInstance().companyCode
            val empCode = SharedPreferUtil.getInstance().workNum
            val pwd = SharedPreferUtil.getInstance().pwd
            CheckNetTimeUtil.checkNetworkTime(this, compCode, empCode, pwd, false, object : UICallBack() {
                override fun onError(msg: String) {}
                override fun onSuccess(obj: Any?) {
                    doScan(result, event)
                }
            })
        } else {
            doScan(result, event)
        }
    }

    /**
     * @param operType 1-跨越卸车扫描，2-跨越托盘绑定扫描,3-跨越手动添加卸车扫描
     */
    private fun doScan(result: String, event: ScanResult) {
        //本地记录扫描最后时间
        sharedPreferUtil.setLongValue(Common.SCAN_LAST_TIME, System.currentTimeMillis())

        if (!StringUtils.isWaybillNo(result) && !StringUtils.isKuaYueWaybillNo(result)) {
            showToast("单号不规范!($result)")
            SoundVibratorManager.playSound(2)
            return
        }

        //获取参与人，月台号信息
        getJoinPeople()
        mDataList.iterator().run {
            while (this.hasNext()) {
                val detail = this.next()
                if (result.startsWith(detail.outsideNo) || result.startsWith(detail.waybillNo)) {
                    var exitChildEntity = false
                    detail.childNos?.forEach { child ->
                        if (result == child.subOutsideNo || result == child.subWaybillNo) {
                            if (child.flag == 1) {
                                if (event.operType != 2) {
                                    showToast("运单号已扫描!($result)")
                                    val currentActivity = ActivityStack.getInstance().currentActivity()
                                    if (currentActivity is KuaYueSpotGoodsActivity || currentActivity is AddBillcodeActivity) {
                                        SoundVibratorManager.playSound(2)
                                    }
                                }
                                //添加托盘绑定数据
                                addPalletBindData(detail, child, ScanResult(result, 1, 2))
                                return
                            }
                            //设置成已扫状态
                            child.flag = 1
                            exitChildEntity = true

                            //组装扫描表,并插入到表中
                            insertScanTable(detail, child)

                            this.remove()
                            mDataList.add(0, detail)
                            loadUIAdapter()
                            val currentActivity = ActivityStack.getInstance().currentActivity()
                            if (currentActivity is KuaYueSpotGoodsActivity) {
                                SoundVibratorManager.playSound(1)
                            } else if (currentActivity is AddBillcodeActivity) {
                                //发送消息处理手动添加结果
                                EventBus.getDefault().post(ScanResult(result, 1, 3))
                            }
                            //添加托盘绑定数据
                            addPalletBindData(detail, child, ScanResult(result, 1, 2))
                            return
                        }
                    }
//                    if (!exitChildEntity) {
//                        //多货处理
//                        val resArr = result.split("-")
//                        //多货标志
//                        detail.remark = "2"
//                        val childEntity = KuaYueChildWaybillEntitiy()
//                        childEntity.flag = 1
//                        childEntity.wbType = 1
//                        childEntity.waybillNo = detail.waybillNo
//                        if (resArr.size == 3) {
//                            //处理跨越子单
//                            childEntity.subWaybillNo = detail.waybillNo + resArr[2]
//                            childEntity.subOutsideNo = result
//                        } else {
//                            //处理壹米子单
//                            childEntity.subWaybillNo = result
//                            childEntity.subOutsideNo = detail.outsideNo + "-" + detail.pieceNum + "-" + result.substring(12, result.length)
//                        }
//                        childEntity.outsideNo = detail.outsideNo
//                        detail.childNos.add(childEntity)
//
//                        //组装扫描表,并插入到表中
//                        insertScanTable(detail, childEntity)
//
//                        this.remove()
//                        mDataList.add(0, detail)
//                        loadUIAdapter()
//                        SoundVibratorManager.playSound(1)
//                        //添加托盘绑定数据
//                        addPalletBindData(detail, childEntity)
//                        return
//                    }
                }
            }
        }

        showToast("运单号不在列表内！")
        SoundVibratorManager.playSound(2)
    }

    /**
     * 组装扫描表，并插入到表中
     */
    private fun insertScanTable(detail: KuaYueTaskDetailEntity, child: KuaYueChildWaybillEntitiy) {
        val scanTable = UnloadScanTable(detail.taskNo, child.waybillNo, child.subWaybillNo, null,
                null, operTypeCode, inputType, detail.remark, detail.areaCode, SharedPreferUtil.getInstance().getValue(Common.USER_CODE),
                SharedPreferUtil.getInstance().getValue(Common.USER_NAME), Constants.GetSysTime(), Constants.GetScanTime(),
                SharedPreferUtil.getInstance().getValue(Common.DEPT_CODE), SysInfo.getInstance().imei, mTaskEntity?.carNo,
                0, null, null, joinWrokNum, joinUserName, deptType,  //waybillType：1-快运，2-快递
                null, platformNo, sharedPreferUtil.getValue(Common.MOVE_IN_PLACE_CODE), 1, null, null,null)
        scanTable.kuayueWaybillNo = child.outsideNo
        scanTable.kuayueChildWaybillNo = child.subOutsideNo
        scanTable.goodsName = detail.goodsName
        scanTable.volume = BigDecimal(detail.volume)
        scanTable.weight = BigDecimal(detail.weight)
        scanTable.chargedWeight = detail.chargedWeight.toString()
        scanTable.pieceNum = detail.pieceNum
        scanTable.nextDeptCode = detail.nextDeptCode
        scanTable.nextDeptName = detail.nextDeptName
        try {
            if (mScanTableDao!!.insert(scanTable) <= 0) {
                SoundVibratorManager.playSound(2)
                showToast("跨越扫描保存失败！")
                return
            }
        } catch (e: SQLException) {
            LogUtil.e(e.toString())
            showToast("跨越扫描保存异常：$e")
            return
        }
    }

    /**
     * 获取装卸参与人
     */
    private fun getJoinPeople() {
        //部门类型
        deptType = sharedPreferUtil.getIntValue(Common.DEPT_TYPE)
        val groupTable = LoadUnloadGroupTableDao().data
        if (groupTable != null) {
            //获取月台号
            platformNo = groupTable.platform
        }
        joinWrokNum = intent.getStringExtra("joinWrokNum")
        joinUserName = intent.getStringExtra("joinUserName")
        if (joinWrokNum == null || joinUserName != null) {
            if (groupTable != null) {
                joinWrokNum = groupTable.userCodes
                joinUserName = groupTable.userNames
            }
        }
        if (joinUserName == null || joinUserName == "") {
            joinUserName = joinWrokNum
        }
        if (joinWrokNum == null || joinUserName == null) {
            if (groupTable != null) {
                joinWrokNum = groupTable.userCodes
                joinUserName = groupTable.userNames
                if (joinUserName == null || joinUserName == "") {
                    joinUserName = joinWrokNum
                }
            } else {
                joinWrokNum = sharedPreferUtil.getValue(Common.USER_CODE)
                joinUserName = sharedPreferUtil.getValue(Common.USER_NAME)
                if (joinUserName == null || joinUserName == "") {
                    joinUserName = joinWrokNum
                }
            }
        }
        //自动检测没有省区的工号，自动添加上去
        val compCode = sharedPreferUtil.companyCode
        if (compCode == null || "" == compCode) {
            showToast("企业编码为空！")
        }
        val userCodes = joinWrokNum!!.split(",").toTypedArray()
        for (i in userCodes.indices) {
            val userCode = userCodes[i]
            if (!userCode.contains("@")) {
                userCodes[i] = "$userCode@$compCode"
            }
        }
        val tempUserCodes = StringBuilder()
        for (userCode in userCodes) {
            tempUserCodes.append("$userCode,")
        }
        joinWrokNum = tempUserCodes.substring(0, tempUserCodes.length - 1)
    }

    /**
     * 根据任务号查询跨越点货明细
     */
    private fun queryTaskDetail() {
        showPgDlg("查询中...")
        val params = mutableMapOf<String, String>()
        if (mTaskEntity != null) {
            params["taskNo"] = mTaskEntity!!.taskNo
        }
        NetRequest().setMethod(NetRequest.Method.GET)
                .setUrl(Constants.URL_QUERY_KUAYUN_TASK_DETAIL)
                .setParams(params)
                .setResponsClazz(KuaYueTaskDetailResponse::class.java)
                .execute(object : UICallBack() {
                    override fun onSuccess(obj: Any?) {
                        dismissPgDlg()
                        mDataList.clear()
                        val response = obj as KuaYueTaskDetailResponse
                        if (!response.data.isNullOrEmpty()) {
                            loadData(response)
                        } else {
                            showToast("无卸车明细！")
                            SoundVibratorManager.playSound(2)
                        }
                        loadUIAdapter()
                    }

                    override fun onError(msg: String?) {
                        dismissPgDlg()
                        showToast(msg)
                        SoundVibratorManager.playSound(2)
                    }
                })
    }

    /**
     * 加载本地数据
     */
    private fun loadData(response: KuaYueTaskDetailResponse) {
        mDataList.addAll(response.data)

        mDataList.forEach { detail ->
            val localData = mScanTableDao!!.getKuaYueData(detail.taskNo, detail.waybillNo, detail.outsideNo)
            localData?.forEach { local ->
                detail.remark = local.remark
                var exitChild = false
                detail.childNos.forEach { child ->
                    if (local.kuayueChildWaybillNo == child.subOutsideNo) {
                        //设置已扫描状态
                        child.flag = 1
                        exitChild = true
                    }
                }
                //添加多货子单
                if (!exitChild) {
                    val childEntity = KuaYueChildWaybillEntitiy()
                    childEntity.flag = 1
                    childEntity.waybillNo = local.waybillNo
                    childEntity.subWaybillNo = local.childWaybillNo
                    childEntity.outsideNo = local.kuayueWaybillNo
                    childEntity.subOutsideNo = local.kuayueChildWaybillNo
                    childEntity.wbType = 1
                    detail.childNos.add(childEntity)
                }
            }
        }

        SoundVibratorManager.playSound(1)
    }

    /**
     * 加载UI列表
     */
    private fun loadUIAdapter() {
        //对刷新的列表重新进行排序
        mDataList = sortList(mDataList)
        if (mAdapter == null) {
            mAdapter = KuaYueSpotGoodsAdapter(this, mDataList, listHead as LinearLayout)
            lv_list.adapter = mAdapter
        } else {
            mAdapter!!.setDataList(mDataList)
            mAdapter!!.notifyDataSetChanged()
        }
        collectData()
    }

    /**
     * 汇总统计
     */
    private fun collectData() {
        var zpiao = 0
        var zjian = 0
        var spiao = 0
        var sjian = 0
        var zWeight = 0.0
        var zVolume = 0.0
        var sWeight = 0.0
        var sVolume = 0.0
        mDataList.forEach { detail ->
            zpiao++
            zjian += detail.childNos.size
            val count = detail.scanCount
            if (count > 0) {
                spiao++
            }
            sjian += count
            zWeight = BigDecimalUtils.add(detail.weight, zWeight)
            zVolume = BigDecimalUtils.add(detail.volume, zVolume)
            sWeight += BigDecimalUtils.mul(BigDecimalUtils.div(detail.weight, detail.pieceNum.toDouble(), 4), count.toDouble())
            sVolume += BigDecimalUtils.mul(BigDecimalUtils.div(detail.volume, detail.pieceNum.toDouble(), 4), count.toDouble())

        }

        tv_piaoNum.text = zpiao.toString()
        tv_jianNum.text = zjian.toString()
        tv_sPiaoNum.text = spiao.toString()
        tv_sJianNum.text = sjian.toString()
        tv_weight.text = BigDecimalUtils.round(zWeight, 2).toString()
        tv_volume.text = BigDecimalUtils.round(zVolume, 2).toString()
        tv_sWeight.text = BigDecimalUtils.round(sWeight, 2).toString()
        tv_sVolume.text = BigDecimalUtils.round(sVolume, 2).toString()
    }

    /**
     * 添加托盘绑定数据
     *
     * @param detail 任务详情实体
     * @param child  子单实体
     * @param operType 1-跨越卸车扫描，2-跨越托盘绑定扫描,3-跨越手动添加卸车扫描
     */
    private fun addPalletBindData(detail: KuaYueTaskDetailEntity, child: KuaYueChildWaybillEntitiy, event: ScanResult) {
        if (cb_palletBind.isChecked) {
            val map = mutableMapOf<String, String>()
            mDataList.forEach { detail ->
                if (detail.areaCode != null) {
                    map[detail.areaCode] = detail.areaCode
                }
                if (map.size >= 5) {
                    val currentActivity = ActivityStack.getInstance().currentActivity()
                    MyDialog.showAlertDialog(currentActivity, "提示", "已超过一个托盘额定绑定票数，请使用托盘绑定！", "确定")
                    SoundVibratorManager.playSound(2)
                    return
                }
            }
            //设置托盘绑定状态
            detail.isPalletBind = 1
            child.isPalletBind = 1

            val currentActivity = ActivityStack.getInstance().currentActivity()
            if (currentActivity is KuaYuePalletBindActivity) {
                //发送消息处理扫描结果
                EventBus.getDefault().post(event)
            }
        }
    }

    /**
     * 取消托盘绑定
     */
    private fun cancelPalletBindData(result: String) {
        mDataList.forEach { detail ->
            detail.childNos.forEach { child ->
                if (child.subWaybillNo == result || child.subOutsideNo == result) {
                    child.isPalletBind = 0
                }
            }
            if(detail.palletBindCount == 0){
                detail.isPalletBind = 0
            }
        }
    }

    /**
     * 判断是否有托盘绑定数据
     */
    private fun exitPalletBindData(): Boolean {
        mDataList.forEach { detail ->
            if (detail.isPalletBind == 1) {
                MyDialog.showAlertDialog(this, "提示", getString(R.string.plateNoFinish), "确定")
                return true
            }
        }
        return false
    }


    /**
     * 数据排序
     * 一级排序 红>黄>白>绿,getType
     * 二级排序 时>比>优>串>标
     */
    private fun sortList(list: MutableList<KuaYueTaskDetailEntity>): MutableList<KuaYueTaskDetailEntity> {
        for (item in list) {
            //设置一级排序
            item.firstSort = item.type
        }
        val sortNameArr = arrayOf("firstSort", "secondSort")
        // true升序,false降序
        val isAscArr = booleanArrayOf(true, true)
        ListUtils.sort(list, sortNameArr, isAscArr)
        return list
    }

    override fun showBack(): Boolean {
        return false
    }

    override fun setBack() {
    }

    override fun setTitle(): String {
        return "到达卸车"
    }

    inner class ListViewAndHeadViewTouchLinstener : OnTouchListener {
        override fun onTouch(arg0: View, arg1: MotionEvent): Boolean {
            //当在列头 和 listView控件上touch时，将这个touch的事件分发给 ScrollView
            val headSrcrollView = listHead.findViewById<HorizontalScrollView>(R.id.horizontalScrollView1)
            headSrcrollView.onTouchEvent(arg1)
            return false
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    fun onMainEventBus(event: ScanResult) {
        if (event.operType == 2 && event.operSource == 2) {
            //托盘发送的扫描信息
            handleScanResult(event.result, event)
        } else if (event.operType == 3 && event.operSource == 3) {
            //跨越手动添加卸车扫描
            handleScanResult(event.result, event)
        } else if (event.operSource == 4) {
            //跨越手动卸车后，刷新列表
            loadUIAdapter()
            //托盘绑定撤销
            cancelPalletBindData(event.result)
        }
    }

}